package TankGame5;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class tankgame5 extends JFrame {
    MyPanel myPanel = null;
    static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
        tankgame5 tankgame5 = new tankgame5();
    }
    public tankgame5(){//设置画板
        System.out.println("请输入你的选择 1：新游戏 2：继续上局");
        String  key = scanner.next();
        myPanel = new MyPanel(key);
        this.add(myPanel);
        //将mp放入到我们的Thread,并启动
        Thread thread = new Thread(myPanel);
        thread.start();
        this.setSize(1300,950);
        this.addKeyListener(myPanel);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        //JFrame中增加相应的关闭窗户的处理
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("监听到关闭窗户了！");
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }
}
